import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  id?: number,
	productId?: number,
	productName?: string,
	status?: number,
	accessType?: number,
	factoryId?: number,
	factoryName?: string,
	remark?: string,
  productIcon?:string,
	script?: any,
  scriptPath?: string,
  deviceIconPath?: string
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/product/product/v2/products';
const Url = '/system/product/product/v2/product';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
/** 1.1.2.2所属厂家（下拉框） */ 
export const getFactorySelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/product/v2/factory', {
    params
  });
}
/** 1.1.2.26产品类型回显 */
export const getProductTypeInfo = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/product/v2/product-info', {
    params
  });
}
/**   */
/** 1.1.3.3选择产品类型信息导出 */ 
export const productexport = (data?: object) => {
  return http.request<commonResult<infoType>>("post", "/system/product/product/v2/export", {
    data
  });
};
/** 1.1.3.4导入产品类型信息 */ 
export const productimport = (data?: object) => {
  return http.request<commonResult<infoType>>("post", "/system/product/product/v2/import", {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
